package com.mccrea.pattern.factory.simplefactory.pizzastore.order;

import com.mccrea.pattern.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.mccrea.pattern.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.mccrea.pattern.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * @Classname SimpleFactory
 * @Description 简单工厂，创建Pizza
 * @Date 2021/5/7 0007 17:59
 * @Created by Mccrea_Gao
 */
public class SimpleFactory {

    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊Pizza");
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
            pizza.setName("奶酪Pizza");
        }
        return pizza;
    }
}
